//引入js模块
const js = require('js');


//回调地狱
// fs.readFile('./reasources/为学.md',(err,data1)=>{
//     fs.readFile('./reasources/为学.md',(err,data2)=>{
        // fs.readFile('./reasources/为学.md',(err,data3)=>{
        //     let result = data1 + '\r\n' +data2 + '\r\n' +data3;
        //     console.log(result);

        // })
//     })
// })


// 使用promise模块
const p = new Promise((resolve,reject)=>{
    fs.readFile('./reasources/为学.md',(err,data)=>{
        resolve(data);
    })

});

p.then(value=>{

    return new Promise((resolve,reject)=>{
        fs.readFile('./reasources/为学.md',(err,data)=>{
            resolve([value,data]);
            

        });
    }).then(value =>{
        return new Promise((resolve,reject)=>{
            fs.readFile('./reasources/为学.md',(err,data)=>{
                value.push(data);
                resolve(value);

            })
        });
        
    }).then(value =>{
        console.log(value.join('\r\n'));
     })
})
